package com.tuotu.gps.entity;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.UUID;

/**
 * Created by XUYEWEN on 2017/8/2.
 */

public class LocationEntity {
    private String time;
    private double lon;
    private double lat;
    private float direction;
    private float speed;

    private static final String JSON_TIME = "TIME";
    private static final String JSON_LON = "LON";
    private static final String JSON_LAT = "LAT";
    private static final String JSON_DIRECTION = "DIR";
    private static final String JSON_SPEED = "SPEED";

    public LocationEntity(String time,double lon,double lat,float direction,float speed) {
        this.time=time;
        this.lon=lon;
        this.lat=lat;
        this.direction=direction;
        this.speed=speed;
    }

    public LocationEntity(JSONObject json) throws JSONException {
        time = json.getString(JSON_TIME);
        lon = json.getDouble(JSON_LON);
        lat = json.getDouble(JSON_LAT);
        direction = (float) json.getDouble(JSON_DIRECTION);
        speed = (float) json.getDouble(JSON_SPEED);
    }

    public JSONObject toJSON() throws JSONException {
        JSONObject json = new JSONObject();
        json.put(JSON_TIME, time);
        json.put(JSON_LON, lon);
        json.put(JSON_LAT, lat);
        json.put(JSON_DIRECTION, direction);
        json.put(JSON_SPEED, speed);
        return json;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public double getLon() {
        return lon;
    }

    public void setLon(double lon) {
        this.lon = lon;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public float getDirection() {
        return direction;
    }

    public void setDirection(float direction) {
        this.direction = direction;
    }

    public float getSpeed() {
        return speed;
    }

    public void setSpeed(float speed) {
        this.speed = speed;
    }
}
